#include "thread.h"


Thread::Thread()
{
}

Thread::~Thread()
{
}

void Thread::start()
{
    pthread_create(&th,NULL,task,this);

    //自动回收
    pthread_detach(th);
}

void Thread::stop()
{
    pthread_cancel(th);
}


void*task(void*arg) //arg就是 子类指针
{
    //多态
   Thread *th = (Thread*)arg;
   th->run();

   return NULL;
}
